/**
 * 
 */
package cn.ivicar.passport.controller.utils;

/**
 * @Author: liurunbin
 * @Description:用户信息管理枚举类
 * @Date: Created in 2017/5/22
 */
public enum CaptchaTypeEnum {
    //0，注册；1，重置密码；2，修改手机号
	REGISTER(0, "register"), RESTPASSWORD(1, "restPassword"), REPLACEMOBILE(2, "replaceMobile");


	private int index;
	private String value;

	CaptchaTypeEnum(int index, String value) {
		this.index = index;
		this.value = value;
	}

	public int getIndex() {
		return index;
	}

	public String getValue() {
		return value;
	}

	public static CaptchaTypeEnum get(int index) {
		switch (index) {
		case 0:
			return REGISTER;
		case 1:
			return RESTPASSWORD;
		case 2:
			return REPLACEMOBILE;
		default:
			return null;
		}
	}

	public static CaptchaTypeEnum get(String code) {

		if (REGISTER.getValue().equalsIgnoreCase(code)) {
			return REGISTER;
		} else if (RESTPASSWORD.getValue().equalsIgnoreCase(code)) {
			return RESTPASSWORD;
		} else if (REPLACEMOBILE.getValue().equalsIgnoreCase(code)) {
			return REPLACEMOBILE;
		} else {
			return null;
		}
	}

}
